package jmine.tec.hydra.script.impl;

import jmine.tec.hydra.script.SendActivationScriptContext;
import jmine.tec.script.persistent.context.impl.AbstractScriptExecutionContext;

/**
 * Contexto de execução de um script de activation por envio.
 * 
 * @author lundberg
 */
public class SendActivationScriptContextImpl extends AbstractScriptExecutionContext<SendActivationInfo> implements
        SendActivationScriptContext {

    private static final String SOURCE = "source";

    private static final String INFO = "info";

    /**
     * Construtor
     */
    public SendActivationScriptContextImpl() {
        // OK
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void beforeExecution() {
        super.beforeExecution();
        this.getParameters().putParameter(INFO, new SendActivationInfo());
    }

    /**
     * {@inheritDoc}
     */
    public SendActivationInfo getResult() {
        return (SendActivationInfo) this.getParameters().getParameterValues().get(INFO);
    }

    /**
     * {@inheritDoc}
     */
    public String getTracer() {
        return null;
    }

    /**
     * Define a origem da chamada
     * 
     * @param source source
     */
    private void setSource(Object source) {
        this.getParameters().putParameter(SOURCE, source, Object.class);
    }

    /**
     * {@inheritDoc}
     */
    public SendActivationScriptContextImpl prepare(Object source) {
        this.setSource(source);
        return this;
    }
}
